#!/bin/bash

# [Start quick]
# 定义数组
arr=(5 2 9 1 5 6)
len=${#arr[@]}

# 冒泡排序
for ((i = 0; i < len - 1; i++)); do
    for ((j = 0; j < len - 1 - i; j++)); do
        # [Start quick3]
        if [[ ${arr[j]} -gt ${arr[$((j+1))]} ]]; then 
            # 交换
            #修改11201416
            # [StartExclude quick]
            # [StartExclude quick3]
            temp=${arr[j]}
            arr[$j]=${arr[$((j+1))]}
            arr[$((j+1))]=$temp
            # [EndExclude quick3]
            # [EndExclude quick]
        fi
        # [End quick3]
    done
done

# [Start quick2]
# 输出排序结果
echo "排序结果: ${arr[@]}"
# [End quick2]
# [End quick]